package com.openbravo.pos.scale;

import com.openbravo.pos.forms.AppLocal;
import com.openbravo.pos.forms.AppProperties;
import com.openbravo.pos.util.StringParser;
import java.awt.Component;

public class DeviceScale
{
  private Scale m_scale;

  public DeviceScale(Component paramComponent, AppProperties paramAppProperties)
  {
    StringParser localStringParser = new StringParser(paramAppProperties.getProperty("machine.scale"));
    String str1 = localStringParser.nextToken(':');
    String str2 = localStringParser.nextToken(',');
    if ("dialog1".equals(str1))
      this.m_scale = new ScaleComm(str2);
    else if ("samsungesp".equals(str1))
      this.m_scale = new ScaleSamsungEsp(str2);
    else if ("fake".equals(str1))
      this.m_scale = new ScaleFake();
    else if ("screen".equals(str1))
      this.m_scale = new ScaleDialog(paramComponent);
    else
      this.m_scale = null;
  }

  public boolean existsScale()
  {
    return this.m_scale != null;
  }

  public Double readWeight()
    throws ScaleException
  {
    if (this.m_scale == null)
      throw new ScaleException(AppLocal.getIntString("scale.notdefined"));
    Double localDouble = this.m_scale.readWeight();
    if (localDouble == null)
      return null;
    if (localDouble.doubleValue() < 0.002D)
      throw new ScaleException(AppLocal.getIntString("scale.invalidvalue"));
    return localDouble;
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.scale.DeviceScale
 * JD-Core Version:    0.6.0
 */